-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Cleanup and tests #2567
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cleanup and tests #2567
Conversation
* Skip MySQL tests if database is not available * Introduce tests namespace
…tests (mongodb#6) * PHPORM-45 Add Query\Builder::toMql() to simplify comprehensive query tests * Move Query/Builder unit tests to a dedicated test class
…th invalid direction (mongodb#7) * Convert only strings, let the driver fail for int values * Add more tests on Builder::orderBy
…lications (mongodb#12) * Add header documentation for classes & traits that can be used in applications * Precise mixed types when possible
…eject invalid array (mongodb#10) The Query\Builder::whereBetween() method can be used like this: whereBetween('date_field', [min, max]) whereBetween('date_field', collect([min, max])) whereBetween('date_field', CarbonPeriod) Laravel allows other formats: the $values array is flatten and the builder assumes there are at least 2 elements and ignore the others. It's a design that can lead to misunderstandings. I prefer to raise an exception when we have incorrect values, rather than trying to guess what the developer would like to do. Support for CarbonPeriod was fixed in Laravel 10: laravel/framework#46720 because the query builder was taking the 1st 2 values of the iterator instead of the start & end dates.
…$not` (mongodb#13) `Query\Builder::whereNot` was simply ignoring the "not" and breaking the built query.
…$not` (mongodb#13) (mongodb#15) `Query\Builder::whereNot` was simply ignoring the "not" and breaking the built query.
…ountDocuments (mongodb#18) https://www.mongodb.com/docs/php-library/current/reference/method/MongoDBCollection-count/ Fix pass options to countDocuments for transaction session
- Add tests on query builder methods that don't need to be fixed. - Throw exception when calling unsupported methods: whereIntegerInRaw, orWhereIntegerInRaw, whereIntegerNotInRaw, orWhereIntegerNotInRaw - Throw an exception when Query\Builder::where is called with only a column name
- Fix support for % and _ in like expression and escaped \% and \_ - Keep ilike and regexp operators as aliases for like and regex - Allow /, # and ~ as regex delimiters - Add functional tests on regexp and not regexp - Add support for not regex
* PHPORM-35 Add various tests on Model _id * Add assertion on expected value * Test _id as array and object * Remove tests for arrays and objects as identifiers when keyType is string --------- Co-authored-by: Andreas Braun <[email protected]>
Codecov ReportPatch coverage:
❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more. Additional details and impacted files@@ Coverage Diff @@
## master #2567 +/- ##
============================================
+ Coverage 89.91% 90.59% +0.67%
- Complexity 712 749 +37
============================================
Files 32 34 +2
Lines 1726 1787 +61
============================================
+ Hits 1552 1619 +67
+ Misses 174 168 -6
☔ View full report in Codecov by Sentry. |
Ignoring StyleCI for the time being - we'll revisit CI tooling in the near future. |
Hello, For a long time, we've tried to get away from Styleci as we didn't have permission to disable it. Php-cs-fixer does the same work, so basically Styleci can be dropped forever... Thanks! |
This is the work of several weeks that was done on a parallel repository (GromNaN/laravel-mongodb) while the ownership of this library to @mongodb was discussed #2499 (comment).
The goal is to improve the maintainability of this library by adding tests, fixing bugs and keep in sync with Laravel changes.
Every commit is a Pull Request reviewed by @alcaeus and/or @jmikola.
Changelog:
ObjectId
andUUID
instances #1Query\Builder::toMql()
to simplify comprehensive query tests #6Query\Builder::whereNot
to use MongoDB$not
operator #13Query\Builder::whereBetween
to acceptCarbon\Period
object #10Query\Builder
methods #9Query\Builder::orderBy()
is used with invalid direction #7Query\Builder::push()
is used incorrectly #5Query\Builder::$paginating
#15Collection::count
forcountDocuments
#18$
inQuery\Builder::orWhere
#20Query\Builder::whereAll($column, $values)
. UseQuery\Builder::where($column, 'all', $values)
instead. #16%
and_
inlike
expression #17